import 'package:boss/ui/page/offersManagement/page/plusOffersMode/page/fullOffers/provider/full_offers_provider.dart';
import 'package:boss/ui/page/offersManagement/page/plusOffersMode/page/fullOffers/widget/full_offers_rule_item.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class FullOffersRuleList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Consumer<FullOffersProvider>(
        builder: (context, fullOffersProvider, _) {
          return ListView.builder(
            shrinkWrap: true,
            physics: NeverScrollableScrollPhysics(),
            itemBuilder: (context, index) {
              var current = fullOffersProvider.rules[index];
              return FullOffersRuleItem(
                key: current.key,
                initFull: current.full,
                initLess: current.less,
                onDelete: () {
                  fullOffersProvider.removeRule(current);
                },
                onFullChanged: (value) {
                  current.full = value;
                },
                onLessChanged: (value) {
                  current.less = value;
                },
              );
            },
            itemCount: fullOffersProvider.rules.length,
          );
        },
      ),
    );
  }
}
